﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FreeWorkflow.DataModels;
using FreeWorkflow;
using FreeWorkflow.Repository;

namespace FreeWorkflow.DataAccess
{
    public class ManageTask : ManageEntity, IDataRepository<WorkItem>
    {
        public object Add(DataModels.WorkItem dataModel)
        {
            context.WorkItems.Add(dataModel);
            context.SaveChanges();
            return dataModel.Id;
        }

        public bool Update(DataModels.WorkItem dataModel)
        {
            context.SaveChanges();
            return true;
        }

        public bool Delete(DataModels.WorkItem dataModel)
        {
            context.WorkItems.Remove(dataModel);
            context.SaveChanges();
            return true;
        }

        public DataModels.WorkItem GetById(object dataModelId)
        {
            return context.WorkItems.Find(dataModelId);
        }

        public ICollection<DataModels.WorkItem> FindAll()
        {
            return context.WorkItems.ToList<DataModels.WorkItem>();
        }
    }
}
